alter function f_getiobcode (@btype int,@bid int,@bno int)
RETURNS nvarchar(4000)
as
begin
  declare @iobcode nvarchar(4000),@bcode nvarchar(200)
  set @iobcode=''
  declare iobcode_cr cursor local forward_only static optimistic for
  select m_bcode from v_tb_depot where relationbtype=@btype and relationbid=@bid and relationbno=@bno
  open iobcode_cr
  fetch next from iobcode_cr into @bcode
  while (@@fetch_status = 0)
  begin
    set @iobcode=@iobcode+@bcode+','
    fetch next from iobcode_cr into @bcode
  end
  close iobcode_cr
  deallocate iobcode_cr
  return @iobcode
end